package uk.ac.ebi.bioinvindex.services;

import static org.jboss.seam.ScopeType.STATELESS;
import org.jboss.seam.annotations.*;
import org.jboss.seam.annotations.web.RequestParameter;
import uk.ac.ebi.bioinvindex.dao.ejb3.OntologyEntryDAOHelper;
import uk.ac.ebi.bioinvindex.dao.ejb3.StudyEJB3DAO;
import uk.ac.ebi.bioinvindex.model.impl.StudyImpl;

/**
 * User: Nataliya Sklyar (nsklyar@ebi.ac.uk)
 * Date: Nov 5, 2007
 */
@Name("studyBeanAction")
@Scope(STATELESS)
public class StudyBeanAction {

	@In
	private StudyEJB3DAO studyEJB3DAO;

	@In
	private OntologyEntryDAOHelper ontologyHelper;

	@RequestParameter
	private String studyId;

	@Factory("studyBean")
	public StudyBean createStudyBean() {
		System.out.println("id = " + this.studyId);
		StudyImpl study = studyEJB3DAO.getById(Long.parseLong(studyId));

		StudyBeanImpl studyBean = new StudyBeanImpl(study);
		studyBean.setOntologyEntryDAOHelper(ontologyHelper);
		studyBean.setStudyDao(studyEJB3DAO);

		return studyBean;
	}

	public String getStudyId() {
		System.out.println("StudyBeanAction.getStudyId = " + studyId);
		return studyId;
	}

	public void setStudyId(String studyId) {
		System.out.println("StudyBeanAction.setStudyId = " + studyId);
		this.studyId = studyId;
	}
}
